home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
cislib_a
/
math.bas
< prev
next >
Wrap
BASIC Source File
|
1995-04-22
|
8KB
|
163 lines
10 REM MATH ROUNDUP
20 REM BY E.D.WALTON 5-15-84
30 REM MARTHA, WVA
40 REM
50 N0=0:N1=1:N559=559:GRAPHICS 17:HOLD=PEEK(N559):POKE N559,N0
60 DIM BYTE$(40),NUM(13)
70 MEM=PEEK(106)-4:POKE 106,MEM-N1:PLACE=MEM*256
80 FOR J=N1 TO 32:READ BYTE:BYTE$(J,J)=CHR$(BYTE):NEXT J
90 DATA 104,104,133,213,104,133,212,104,133,215,104,133,214,162,4,160,0,177,212,145,214,200,208,249,230,213
100 DATA 230,215,202,208,240,96
110 Z=USR(ADR(BYTE$),224*256,PLACE)
120 A=60*8:FOR I=N0 TO 23:READ X:POKE PLACE+A+I,X:NEXT I
130 DATA 0,0,0,0,0,0,255,192,0,0,0,0,0,0,255,0,192,192,192,192,192,192,192,192
140 N2=2:N3=3:N4=4:N5=5:N6=6:N7=7:N8=8:N9=9:N10=10:N12=12:N17=17:N18=18:N48=48:N58=58:N84=84
150 N85=85:N89=89:N224=224:N255=255:N708=708:N756=756
160 A=PEEK(N708):DIM X$(1),ANS$(N3)
170 CLOSE #N2:OPEN #N2,N4,N0,"K:"
180 POKE N756,N224:POKE N559,HOLD
190 GRAPHICS N18:? #N6," MATH ROUND-UP"
200 FOR I=N0 TO N255:POKE N708,INT(I/16):POKE 712,I:NEXT I:POKE N708,A:POKE 712,N0
210 POKE N84,N10:? #N6;" PRESS ANY KEY TO BEGIN":POKE 764,N255
220 A=PEEK(764):IF A=N255 THEN 220
230 FOR I=1 TO 12:READ X:NUM(I)=X:NEXT I
240 DATA 12,1,11,2,10,3,9,4,8,5,7,6
250 GRAPHICS N17:? #N6;"TYPE IN YOUR CHOICE FOR THIS LESSON":COR=N0:WRG=N0:TOTAL=N0
260 POKE N84,N6:? #N6;"(1) ADDITION":? #N6
270 ? #N6;"(2) SUBTRACTION":? #N6
280 ? #N6;"(3) MULTIPLICATION":? #N6
290 ? #N6;"(4) DIVISION"
300 GET #N2,X:IF X<49 OR X>52 THEN GOTO 300
310 X$=CHR$(X)
320 X=VAL(X$)
330 ON X GOTO 350,580,800,1050
340 GOTO 260
350 GRAPHICS N18:POKE N84,N1:? #N6;" addition facts ":POKE N84,N7:? #N6;"WHICH SET? (1 TO 12)";
360 POKE N84,N9:? #N6;"ENTER SET AND PRESS <RETURN>":INPUT #N2;X:PROBLEM=N0:POKE N756,N224
370 PROBLEM=PROBLEM+N1:TRIES=N0
380 GOSUB 1540
390 ANS=M+X
400 GRAPHICS N18:GOSUB 1350:POKE N84,N3
410 IF M>N9 AND X<N10 THEN POKE N85,N9:? #N6;M:POKE N85,N7:? #N6;" + ";X:POKE N85,8:? #N6;"___"
420 IF M>N9 AND X>N9 THEN POKE N85,N9:? #N6;M:POKE N85,N7:? #N6;"+ ";X:POKE N85,N7:? #N6;"____"
430 IF M<N10 AND X<N10 THEN POKE N85,N10:? #N6;M:POKE N85,N7:? #N6;" + ";X:POKE N85,N8:? #N6;"___"
440 IF M<N10 AND X>N10 THEN POKE N85,N10:? #N6;M:POKE N85,N7:? #N6;"+ ";X:POKE N85,N7:? #N6;"____"
450 ANS$=STR$(ANS):J=LEN(ANS$):TENS=N0:TEMP=N0
460 FOR I=N1 TO J
470 GET #N2,A:IF A<N48 OR A>N58 THEN GOTO 470
480 X$=CHR$(A):A=VAL(X$)
490 IF J=N2 AND I=N1 THEN TENS=A*N10:TEMP=A:GOSUB 1320
500 IF J=I THEN GUESS=TENS+A:TEMP=GUESS:GOSUB 1320
510 NEXT I
520 TRIES=TRIES+N1
530 IF GUESS=ANS THEN GOSUB 1490:GOTO 560
540 IF GUESS<>ANS AND TRIES<N3 THEN GOSUB 1500:GOSUB 1510:GOTO 400
550 IF TRIES=N3 THEN GOSUB 1520:GRAPHICS N18:GOSUB 1350
560 IF PROBLEM<N12 THEN GOTO 370
570 TOTAL=COR+WRG:GOTO 1360
580 GRAPHICS N18:POKE N84,N1:? #N6;" subtraction facts ":POKE N84,N7:? #N6;"WHICH SET? (1 TO 12)";
590 POKE N84,N9:? #N6;"ENTER SET AND PRESS <RETURN>":INPUT #N2;X:PROBLEM=N0:POKE N756,N224
600 PROBLEM=PROBLEM+N1:TRIES=N0
610 GOSUB 1540:M=M+(X-1)
620 ANS=M-X
630 GRAPHICS N18:GOSUB 1350:POKE N84,N3
640 IF M>N9 AND X<N10 THEN POKE N85,N9:? #N6;M:POKE N85,N7:? #N6;" - ";X:POKE N85,N8:? #N6;"___"
650 IF M>N9 AND X>N9 THEN POKE N85,N9:? #N6;M:POKE N85,N7:? #N6;"- ";X:POKE N85,N7:? #N6;"____"
660 IF M<N10 AND X<N10 THEN POKE N85,N10:? #N6;M:POKE N85,N7:? #N6;" - ";X:POKE N85,N8:? #N6;"___"
670 ANS$=STR$(ANS):J=LEN(ANS$):TENS=N0:TEMP=N0
680 FOR I=N1 TO J
690 GET #N2,A:IF A<N48 OR A>N58 THEN GOTO 690
700 X$=CHR$(A):A=VAL(X$)
710 IF J=N2 AND I=N1 THEN TENS=A*N10:TEMP=A:GOSUB 1320
720 IF J=I THEN GUESS=TENS+A:TEMP=GUESS:GOSUB 1320
730 NEXT I
740 TRIES=TRIES+N1
750 IF GUESS=ANS THEN GOSUB 1490:GOTO 780
760 IF GUESS<>ANS AND TRIES<N3 THEN GOSUB 1500:GOSUB 1510:GOTO 630
770 IF TRIES=N3 THEN GOSUB 1520:GRAPHICS N18:GOSUB 1350
780 IF PROBLEM<N12 THEN GOTO 600
790 TOTAL=COR+WRG:GOTO 1360
800 GRAPHICS N18:POKE N84,N1:? #N6;"multiplication facts":POKE N84,N7:? #N6;"WHICH SET? (1 TO 12)";
810 POKE N84,N9:? #N6;"ENTER SET AND PRESS <RETURN>":INPUT #N2;X:PROBLEM=N0
820 GRAPHICS N18
830 PROBLEM=PROBLEM+N1:TRIES=N0:GOSUB 1350:GOSUB 1540:ANS=M*X
840 POKE N84,N3:POKE N85,N9
850 IF X>N9 AND M>N9 THEN ? #N6;X:POKE N85,N7:? #N6;"X ";M:POKE N85,N7:? #N6;"____"
860 IF X<N10 AND M>N9 THEN POKE N85,N10:? #N6;X:POKE N85,N7:? #N6;"X ";M:POKE N85,N7:? #N6;"____"
870 IF X<N10 AND M<N10 THEN POKE N85,N10:? #N6;X:POKE N85,N7:? #N6;"X ";M:POKE N85,N7:? #N6;"____"
880 IF X>N9 AND M<N10 THEN ? #N6;X:POKE N85,N7:? #N6;"X ";M:POKE N85,N7:? #N6;"____"
890 ANS$=STR$(ANS):J=LEN(ANS$):TENS=N0:TEMP=N0:HUNS=N0
900 FOR I=N1 TO J
910 GET #N2,A:IF A<N48 OR A>N58 THEN GOTO 910
920 X$=CHR$(A):A=VAL(X$)
930 IF J=N3 AND I=N1 THEN HUNS=A*100:TEMP=A:GOSUB 1320
940 IF J=N2 AND I=N1 THEN TENS=A*N10:TEMP=A:GOSUB 1320
950 IF J=N3 AND I=N2 THEN TENS=A*N10:TEMP=TEMP*N10+A:GUESS=HUNS+TENS:GOSUB 1320
960 IF J=I THEN GUESS=HUNS+TENS+A:TEMP=GUESS:GOSUB 1320
970 NEXT I
980 TRIES=TRIES+N1
990 IF GUESS=ANS THEN GOSUB 1490:GOTO 1020
1000 IF GUESS<>ANS AND TRIES<N3 THEN GOSUB 1500:GOSUB 1510:GOTO 840
1010 IF TRIES=N3 THEN GOSUB 1520:GRAPHICS N18:GOSUB 1350
1020 IF PROBLEM<N12 THEN GOTO 820
1030 TOTAL=COR+WRG
1040 GOTO 1360
1050 GRAPHICS N18:POKE N84,N1:? #N6;" division facts":POKE N84,N7:? #N6;"WHICH SET? (1 TO 12)";
1060 POKE N84,N9:? #N6;"ENTER SET AND PRESS <RETURN>":INPUT #N2;X:PROBLEM=N0
1070 PROBLEM=PROBLEM+N1:TRIES=N0:GOSUB 1540:ANS=M*X
1080 DIVISOR=ANS:ANS=DIVISOR/X
1090 GRAPHICS N18:POKE N756,MEM:GOSUB 1350
1100 IF X<N10 THEN POKE N84,N4:POKE N85,N7:? #N6;" \]]]":POKE N85,N6:? #N6;X;" ^";DIVISOR
1110 IF X>N9 THEN POKE N84,N4:POKE N85,N7:? #N6;" \]]]":POKE N85,N5:? #N6;X;" ^";DIVISOR
1120 ANS$=STR$(M):J=LEN(ANS$):TENS=0
1130 IF J=N1 AND DIVISOR>N9 THEN L=X-N1
1140 IF J=N1 AND DIVISOR<N10 THEN L=X+N1
1150 IF J<>1 AND X<N10 THEN L=INT(DIVISOR/N10)
1160 FOR I=N1 TO J
1170 GET #N2,A:IF A<N48 OR A>N58 THEN GOTO 1170
1180 X$=CHR$(A):A=VAL(X$)
1190 IF J=N2 AND I=N1 AND X>L THEN TENS=A*N10:TEMP=A:GOSUB 1300
1200 IF J=N2 AND I=N1 AND X<=L THEN TENS=A*N10:TEMP=A:GOSUB 1310
1210 IF J=I AND X>L THEN GUESS=TENS+A:TEMP=GUESS:GOSUB 1300
1220 IF J=I AND X<=L THEN GUESS=TENS+A:TEMP=GUESS:GOSUB 1310
1230 NEXT I
1240 TRIES=TRIES+N1
1250 IF GUESS=ANS THEN GOSUB 1490:GOTO 1280
1260 IF GUESS<>ANS AND TRIES<N3 THEN GOSUB 1500:GOSUB 1510:GOTO 1090
1270 IF TRIES=N3 THEN GOSUB 1520:GRAPHICS N18:GOSUB 1350
1280 IF PROBLEM<N12 THEN GOTO 1070
1290 TOTAL=COR+WRG:GOTO 1360
1300 POKE N84,N3:POKE N85,N10:? #N6;TEMP;:RETURN
1310 POKE N84,N3:POKE N85,N9:? #N6;TEMP;:RETURN
1320 IF J=N3 THEN POKE N85,N8:? #N6;TEMP;:RETURN
1330 IF J=N2 THEN POKE N85,N9:? #N6;TEMP;:RETURN
1340 IF J=N1 THEN POKE N85,N10:? #N6;TEMP;:RETURN
1350 ? #N6;"RIGHT ";COR;" WRONG ";WRG:RETURN
1360 GRAPHICS N17:? #N6;" YOU HAVE FINISHED THIS LESSON":? #N6
1370 ? #N6;" you had ";COR;" correct and ";WRG;" incorrect answers"
1380 PCT=COR/TOTAL*100:SCORE=INT(PCT)
1390 ? #N6:? #N6;" YOUR SCORE IS ";SCORE;" %":? #N6:? #N6
1400 CLOSE #N2:OPEN #N2,N4,N0,"K:"
1410 IF SCORE>N89 THEN ? #N6;"GREAT JOB!! YOU HAVE REALLY WORKED HARD!":GOTO 1450
1420 IF SCORE>79 THEN ? #N6;"GOOD WORK!, BUT YOU SHOULD STUDY YOUR FACTS HARDER":GOTO 1450
1430 IF SCORE>69 THEN ? #N6;" you should study your facts harder!":GOTO 1450
1440 IF SCORE<70 THEN ? #N6;" try again unsatisfactory work!"
1450 ? #N6:? #N6:? #N6:? #N6;" DO YOU WANT TO TRY ANOTHER LESSON?":? #N6:? #N6;" TYPE (Y OR N)":GET #N2,X
1460 IF X=N89 THEN RESTORE 240:GOTO 230
1470 GRAPHICS N18:? #N6:? #N6:? #N6:? #N6;" LESSON ENDED":FOR J=N1 TO 1500:NEXT J
1480 END
1490 POKE N84,N10:POKE N85,N0:? #N6;" YOU ARE CORRECT!!":COR=COR+N1:FOR J=N1 TO 300:NEXT J:RETURN
1500 POKE N84,N10:POKE N85,N4:? #N6;" TRY AGAIN!":FOR J=N1 TO 300:NEXT J:WRG=WRG+N1:RETURN
1510 GRAPHICS N18:GOSUB 1350:RETURN
1520 POKE N84,N10:POKE N85,N0:? #N6;"SORRY THE ANSWER IS ";ANS;" ! ":WRG=WRG+N1
1530 FOR J=N1 TO 500:NEXT J
1540 FOR I=N1 TO N3:ANS$(I)=" ":NEXT I
1550 N=13-PROBLEM
1560 L=INT(RND(1)*N+1)
1570 M=NUM(L)
1580 FOR J=L TO 12
1610 NUM(J)=NUM(J+1)
1620 NEXT J
1630 RETURN